﻿<title>商品</title>
<link type="text/css" href="${ctx}/resources/css/ace.min.1.css"  rel="stylesheet" />
<table>

<tr>
<th>产品分类 :</th>
	<th width="70px;" class="label label-sm label-light arrowed"><a href="${ctx}/admin/goodsPro/list${suffix}">不限</a></th>
	<#assign sTypes = dicSetting.getParameterMap("goods.category")> 
	<#list sTypes?keys as key>
		<#if key_index lt 10>
			<th width="70px;" class="label label-sm label-warning arrowed"><a href="${ctx}/admin/goodsPro/list${suffix}?categoryId=${key}">${sTypes[key]}</a></th>
		</#if>
	</#list>
</tr>
<tr>
<tr>
<th>产品状态:</th>
<th width="70px;" class="label label-sm label-light arrowed"> <a href="${ctx}/admin/goodsPro/list${suffix}" >不限</a> </th>
<th width="70px;" class="label label-sm label-success arrowed"> <a href="${ctx}/admin/goodsPro/list${suffix}?state=1" >正常</a> </th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/goodsPro/list${suffix}?state=2" >禁用</a> </th>
</tr>
</table>


<div class="hr hr-5"></div>
<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
			<table id="sample-table-1" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>ID</th>
						<th>产品名称</th>
						<th>产品图片</th>
						
						<th>型号</th>
						<th>厂家</th>
						<th>编码</th>
						<th>类别</th>
						
						<th>适用设备</th>
						<th>适用范围</th>
						<th>分类</th>
						<th>产品描述</th>
						
						<th>创建时间</th>
						<th>最近修改时间</th>
						<th>状态</th>
						<#if adminRole == 1>
							<th>操作</th>
						</#if>
					</tr>
				</thead>
				<tbody>
				<#list pager.itemList as u>
					<tr>
						<td>${u.id}</td>
						<td>${u.name!}</td>
						<td>
							<#list gsonUtils.getImgsJsonList(u.urlList) as url>
								<span class="profile-picture">
									<img style="height:105px;width:250px;" class="editable img-responsive" src="${tagUtils.getFileFullPath(url)}" />
								</span>
								<#break>
							</#list>
						</td>
						
						<td>${u.goodsModel!}</td>
						<td >
							<span class="label label-sm label-warning arrowed">
								${dicSetting.getParameterValue("goods.brand." + u.brand)!}
							</span>
						</td>
						
						
						
						<td>${u.goodsCode!}</td>
						<td >
							<span class="label label-sm label-warning arrowed">
								${dicSetting.getParameterValue("goods.category." + u.categoryId)!}
							</span>
						</td>
						<td>${u.baseStationModel!}</td>
						<td>${u.net!}</td>
						<td>${u.computerCardName!}</td>
						
						
						<#assign content=u.production>
						<#if content?length lt 50>
							<td>${content?html}</td>
						<#else>
							<td>${content?substring(0,50)?html}</td>
						</#if>
						
						
						
						
						
						
						
						
						
						
						<td>
							<#if u.createTime??>
								${tagUtils.formatDate(u.createTime)!}
							</#if>
						</td>
						<td>
							<#if u.modifyTime??>
								${tagUtils.formatDate(u.modifyTime)!}
							</#if>
						</td>
						<td>
						<#if u.state == 2>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doState(this,'${u.id}');" id="off_state"/>
							<span class="lbl"></span>
						<#else>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doState(this,'${u.id}');" checked="checked" id="off_state"/>
							<span class="lbl"></span>
						</#if>
						</td>
						<#if adminRole == 1>
							<td>
								<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
									<a class="green" href="${ctx}/admin/goodsPro/edit-${u.id}${suffix}" alt="编辑">
										<i class="icon-pencil bigger-130" title="编辑"></i>
									</a>
									<a class="green" href="${ctx}/admin/goodsPro/${u.id}/detail${suffix}">
										查看详情
									</a>
									<a class="red" onclick="isDel('${ctx}/admin/goodsPro/delete-${u.id}${suffix}')" alt="Delete">
										<i class="icon-trash bigger-130" title="删除"></i> 
									</a>
								</div>
							</td>
						</#if>
					</tr>
				</#list>
				</tbody>
			</table>
		</div>
	
		<div class="hr hr-18 dotted hr-double"></div>
		<@h.page pager=pager action="${ctx}/admin/goodsPro/list${suffix}" />
	</div><!-- /span -->
</div><!-- /row -->

<#if errorMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer red"></i>
		<span class="pink">${errorMsg!}</span>
	</h4>
</#if>

<#if infoMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer green"></i>
		<span class="pink">${infoMsg}</span>
	</h4>
</#if>

<script>
function isDel(url){
		if(!confirm("确认要删除？")){ 
				return false;		
		}else{
			location.href = url;
		}
	}
function doState(checkbox,id) {
<#if adminRole == 1>
	if(checkbox.checked) {
		$.ajax({
		async : false,
        cache : false,
        type : 'POST',
        dataType :JSON,
        url : "${ctx}/admin/goodsPro/on?id="+id,
        error : function(data){
        	var str = data.responseText;
        	if(str.indexOf("true")>0){
				location.href = location.href;
			}else{
			}
        }
		});
	} else {
		$.ajax({
		async : false,
        cache : false,
        type : 'POST',
        dataType :JSON,
        url : "${ctx}/admin/goodsPro/off?id="+id,
        error : function(data){
        	var str = data.responseText;
        	if(str.indexOf("true")>0){
				location.href = location.href;
			}else{
			}
        }
		});
	}
</#if>
	}
$(document).ready(function(){
	RP.addBreadcrumb([ {name:"商品列表", active: true}]);
	<#if adminRole == 1>
	$("#breadcrumbs ul").append('&nbsp;&nbsp;&nbsp;&nbsp;<a href="${ctx}/admin/goodsPro/add${suffix}"><i class="icon-zoom-in"></i><span class="label label-warning arrowed-in arrowed-in arrowed-right">新增商品</span></a>');
	</#if>
});
</script>